document.ready = function (callback) {
    // /兼容FF,Google
    if (document.addEventListener) {
        document.addEventListener('DOMContentLoaded', function () {
            document.removeEventListener('DOMContentLoaded', arguments.callee, false);
            callback();
        }, false)
    }
    // 兼容IE
    else if (document.attachEvent) {
        document.attachEvent('onreadystatechange', function () {
            if (document.readyState == "complete") {
                document.detachEvent("onreadystatechange", arguments.callee);
                callback();
            }
        })
    } else if (document.lastChild == document.body) {
        callback();
    }
};

/// init document ready function ///
document.ready(function () {

    let svg = SVGUtil.create("svg");
    SVGUtil.namespace(svg);


    svg.setAttribute("width", "100%");
    svg.setAttribute("height", "100%");
    // svg.setAttribute("x", "400");
    // svg.setAttribute("y", "400");

    //使用viewBox进行缩放
    // svg.setAttribute("preserveAspectRatio", "xMidYMid meet");
    //svg.setAttribute("viewBox", "0 0 100% 100%");


    //将svg注入到全局变量
    window.svg = svg;

    var desc = SVGUtil.create("desc");
    desc.innerHTML = "SVG Demo"
    svg.appendChild(desc);

    //document.querySelector("#container").appendChild(svg);

    //画框
    //drawRact();

});


function drawRact(){

    var rect = SVGUtil.create("rect");
    rect.setAttribute("width", "100");
    rect.setAttribute("height", "100");
    rect.setAttribute("x", "50");
    rect.setAttribute("y", "50");
    rect.style.cssText = "fill:blue;stroke:pink;stroke-width:5;fill-opacity:0.1;stroke-opacity:0.9";
    svg.appendChild(rect);
}

